<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>学生信息</title>
    <link th:replace="~{common::common_head}">
</head>

<body class="">
<div class="wrapper">
    <div th:insert="~{common::sidebar(active='student_info.html')}"></div>
    <div class="main-panel">
        <!-- Navbar导航栏 -->
        <nav th:replace="~{common::navbar}"></nav>
        <!-- End Navbar -->
            <div class="panel-header">
                <form id="search_form" th:action="@{/patient/search}">
                    <div class="header text-center">
                        <h2 class="title">个人信息</h2>
                        <p class="category">填写补充或修改自己的学生信息。</p>
                    </div>
                </form>
            </div>
        <div class="content">
            <div class="row">
                <div class="col-md-8 offset-2">
                    <div class="card">
                        <div class="card-header">
                            <h5 class="title">学生信息</h5>
                        </div>
                        <div class="card-body">
                            <form id="student_form" method="post" th:action="@{/student/studentInfo/update}">
                                <!--隐藏域-->
                                <input type="text" name="info_id" th:value="${student.getInfoId()}" hidden="hidden" required="required">

                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label>学生姓名</label>
                                            <input required name="name" type="text" class="form-control"  th:value="${student.getName()}" placeholder="请输入姓名">
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label>身份证号</label>
                                            <input name="id" type="text" class="form-control" th:value="${student.getId()}" required="required"
                                                   maxlength="18" onkeyup="value=value.replace(/[^\dxX]/g,'')" placeholder="请输入正确的身份证号码">
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label>学生性别</label>
                                            <select name="gender" class="form-control" placeholder="选择性别...">
                                                <option value="1" th:selected="${student.getGender()==1}">男</option>
                                                <option value="0" th:selected="${student.getGender()==0}">女</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label>学生学号</label>
                                            <input name="stu_num" type="number" class="form-control" placeholder="请输入学号。" th:value="${student.getStuNum()}" required="required">
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label>所在学校</label>
                                            <input name="school" type="text" class="form-control" th:value="${student.getSchool()}" required="required">
                                        </div>
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-md-4 pr-2">
                                        <div class="form-group">
                                            <label>年级</label>
                                            <select name="grade" id="grade" type="text" class="form-control" placeholder="选择年级" onchange="inpatientSelect()" th:value="${student.getGrade()}">
                                                <option selected value="0">请选择年级...</option>
                                                <option value="大一" th:selected="${student.getGrade()=='大一'}">大一</option>
                                                <option value="大二" th:selected="${student.getGrade()=='大二'}">大二</option>
                                                <option value="大三" th:selected="${student.getGrade()=='大三'}">大三</option>
                                                <option value="大四" th:selected="${student.getGrade()=='大四'}">大四</option>
                                            </select>

                                        </div>
                                    </div>
                                    <div class="col-md-4 px-2">
                                        <div class="form-group">
                                            <label>专业</label>
                                            <input name="major" type="text" class="form-control" th:value="${student.getMajor()}" required="required">
                                        </div>
                                    </div>
                                    <div class="col-md-4 px-1">
                                        <div class="form-group">
                                            <label>班级</label>
                                            <input name="stu_class" type="text" class="form-control" th:value="${student.getStuClass()}" required="required">
                                        </div>
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-md-8 offset-3">
                                       <button type="reset" class="btn-warning btn btn-lg col-4">重置</button>
                                        <input type="button" onclick="update()" class="btn-primary btn btn-lg col-4" value="登记">
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div th:insert="~{common::footer}"></div>
    </div>
</div>



<script>
    /**
     * 学生登记提交
     */
    function update(){
        var formData = $("#student_form").serialize();
        $.ajax({
            sync:false,
            url:'/student/userInfo/update',
            data: formData,
            method:'post',
            dataType:'text',
            success:function(result){
                if(result==='更新成功！'){
                    demo.showNotification('success',result);
                    return;
                }
                demo.showNotification('danger',result);
            }
        })

    }

</script>
<!--通用footerJs-->
<script th:replace="~{common::footerJs}"></script>
</body>
</html>
